<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    // 5、鸭子（2只脚）和绵羊（4只脚）一共35只，笼子里一共有94只脚，用js实现计算出鸭子和绵羊分别多少只？
        var duck = 0,
            sheep = 0;
        //死循环
        while (true) {
            //鸭子,每次循环加一次鸭子
            // duck = duck + 1;
            sheep++;
            //绵羊
            // sheep = 35 - duck;
            // 每买一只绵羊，鸭子的数量就从35只减一只
            duck = 35 - sheep;
            //一共有94只脚成立
            if (duck * 2 + sheep * 4 == 94) {
                console.log(duck, sheep);//23 12
                break;//break跳出循环
            }
        }
    </script>
</body>
</html>